package com.gilight.base.controller;

import com.gilight.base.admin.advert.AdminAdvertService;
import com.gilight.base.admin.brand.AdminBrandService;
import com.gilight.base.base.ResultEntity;
import com.gilight.base.base.exception.ServiceException;
import com.gilight.base.service.SysUserZzjgService;
import com.gilight.base.util.MapUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * @author liken
 * 品牌管理
 */
@RestController
@RequestMapping("/web/admin-brand")
public class AdminBrandController {
    @Autowired
    private AdminBrandService adminBrandService;
    @Autowired
    private SysUserZzjgService sysUserZzjgService;
    /**
     *
     * @param brandName  品牌标题
     * @param imgUrl 品牌图片地址
     * @param status 品牌状态
     * @return
     * @throws ServiceException
     */
    @ApiOperation(value = "创建")
    @RequestMapping(value = "/create")
    public ResultEntity create(
            String brandName,
            String imgUrl,
            Integer status,
            Integer orderC,
            String myimgUrl,
            String favicon,
            String inBuildUrl ) throws ServiceException{


        String cr = adminBrandService.create(brandName,imgUrl,status,orderC,myimgUrl,favicon,inBuildUrl);
        ResultEntity resultEntity = new ResultEntity(cr);
        return resultEntity;

    }

    /**
     * 删除
     * @param adId 品牌ID
     * @return
     * @throws ServiceException
     */
    @ApiOperation(value = "删除")
    @RequestMapping(value = "/delete")
    public ResultEntity delete(
            Long adId
            ) throws ServiceException{
        String cr = adminBrandService.delete(adId);
        ResultEntity resultEntity = new ResultEntity(cr);
        return resultEntity;
    }

    /**
     *
     * @param adId 品牌ID
     * @param imgUrl 品牌图片地址
     * @param status 品牌状态
     * @return
     * @throws ServiceException
     */
    @ApiOperation(value = "更新")
    @RequestMapping(value = "/update")
    public ResultEntity edit(
            Long adId,
            String brandName,
            String imgUrl,
            Integer status,
            Integer orderC,
            String myimgUrl,
            String favicon,
            String inBuildUrl) throws ServiceException{
        String cr = adminBrandService.edit(adId,brandName,imgUrl,status,orderC,myimgUrl,favicon,inBuildUrl);
        ResultEntity resultEntity = new ResultEntity(cr);
        return resultEntity;
    }

    /**
     *
     * @param page
     * @param limit
     * @param status 品牌状态
     * @return
     * @throws ServiceException
     */
    @ApiOperation(value = "所有")
    @RequestMapping(value = "/list")
    public ResultEntity list(
            Integer page,
            Integer limit,
            Integer status
            ) throws ServiceException{

        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setData(adminBrandService.list(page,limit,status));
        return resultEntity;
    }

}
